<?php
    $a = [
            '张三',
            '星辰',
            '众人兑',
            'Qxh',
            '焕革儿',
            '?万红?',
            '詹洪',
            '静',
            '时迁~人变',
            '问路',
            '幸福在哪里',
            '奋斗在中年',
            'A   OMG',
            '冬之雪',
            '西域的骆驼',
            '田园',
            '符纯平',
            '风的旋律',
            '龚玲玲',
            '张久玉',
            '℡Χī小沫',
            '以旁观者的姿态看生活',
            '杉杉',
            '杉杉',
            '幸福美好时光',
            '老程哥',
            '皮卡丘',
            'Jy',
            '生如夏花',
            '月亮后有贝壳吗',
            '静子',
            '腊梅花开',
            '杨六郎',
    ];
    ?>

<html>
<head>
    <title>
        抽奖
    </title>
</head>
<body>
    <div style="text-align: center"><h1>年会</h1></div>
    <table cellpadding="0" cellspacing="0" border="1px solid black" style="width:80%;margin: 0 auto" >
        <thead>
            <tr>
                <th>姓名</th>
                <th>姓名</th>
                <th>姓名</th>
                <th>姓名</th>
                <th>姓名</th>
            </tr>
        </thead>
        <tbody>
        <tr id="user">
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        </tbody>
    </table>

    <div style="text-align: center;margin-top: 30px;height: 100px" ><button id="start" style="width: 200px; height: 50px;font-size: 30px" >START</button></div>


    <script src="jquery-1.8.2.min.js"></script>
    <script>
        $(function () {
            var all = <?php echo json_encode($a)?>;
            var users = $("#user").children();
            var time = 150;
            var rank = setInterval(function () {
                test(users,all)
            },5);

            clearInterval(rank);

            $("#start").click(function () {
                clearInterval(rank);
                time = 150;
                 rank = setInterval(function () {
                    test(users,all)
                },5);
            });
            function test(users,all) {
                if(time == 0){
                    clearInterval(rank);
                }else{
                    for(var i = 0 ; i<users.length ; i++){
                        var num = Math.floor(Math.random()*100);
                        $(users[i]).text(all[num]);
                    }
                    time--;
                }
            }
        })
    </script>
</body>
</html>
